<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type='text/javascript' src='../js/vue.js'></script>
    <script type='text/javascript' src=''></script>

</head>

<body>

    <div id="root">
    </div>
    <script>
        Vue.config.productionTip = false;


        const student = Vue.extend({
            template: `
                <div>
                    <h2>学生名称：{{studentName}}</h2>
                    <h2>学生地址：{{address}}</h2>
                    <button @click='showName'>点我提示姓名</button>
                </div>
            `,
            data() {
                return {
                    studentName: 'SONG',
                    address: 'GZ',
                }
            },
            methods: {
                showName() {
                    alert(this.studentName)
                }
            }
        })

        const school = Vue.extend({
            template: `
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <button @click='showName'>点我提示学校名</button>
                    <student></student>
                </div>
            `,
            data() {
                return {
                    schoolName: 'CQBZ',
                    address: 'CQ',
                }
            },
            components: {
                student
            },
            methods: {
                showName() {
                    alert(this.schoolName)
                }
            }
        })

        const hello = Vue.extend({
            template:`
                <h1>
                    {{msg}}
                </h1>
            `,
            data(){
                return {
                    msg:'hello'
                }
            }
        })

        const app = Vue.extend({
            template:`
                <div>
                    <hello/>
                    <school/>
                </div>
            `,
            components:{
                hello,
                school
            }
        })

        new Vue({
            template:`<app/>`,
            el:'#root',
            // 注册组件，局部注册
            components: {
                app
            }
        })

    </script>
</body>

</html>